<template>
    <div>
        <el-upload action="" list-type="picture-card" :http-request="handlePictureCardPreview" ref="upload"
            :on-change="uploadImgFn" :on-preview="handlePictureCardPreview" :before-upload="beforeAvatarUpload"
            :on-remove="handleRemove">
            <i class="el-icon-plus"></i>
        </el-upload>
    </div>
</template>

<script>
export default {
    handlePictureCardPreview() {
        
    },
    beforeAvatarUpload() {
        
    },
    uploadCloud(upFile, fileList) {
        let file = upFile.raw
        let num = crypto.randomUUID()
        let path = `houtaiguanli/wuxianshangBox/${num}_${file.name}`
        wuxian.uploadImg({ "path": path }).then((res) => {
            let result = res.data
            const data = new FormData();
            data.append('key', path);
            data.append('Signature', result.authorization);
            data.append('x-cos-security-token', result.token);
            data.append('x-cos-meta-fileid', result.cos_file_id);
            data.append('file', file, path); 
            console.log('11111data', data)
            wuxian.generalAPI(result.url, data).then((a) => {
                wuxian.downloadImg({
                    file_list: [
                        {
                            fileid: res.data.file_id,
                            max_age: 0
                        }
                    ]
                }).then((res) => {
                    console.log(res)
                    let yunurl = res.data.file_list[0].download_url
                    this.basicInfo.display_url = yunurl
                    this.$message.success("上传成功")
                })
            })
        })
        if (fileList.length >= 1) {
            this.uploadDisabled = true
        }
    },
    }
</script>

<style lang="less" scoped>

</style>